#pragma once

// imaterialsystem
#define MATSYS_FINDMATERIAL				71
#define MATSYS_FIRSTMATERIAL			73
#define MATSYS_GETMATERIAL				76
#define MATSYS_GETNUMMATERIALS		    77

// imaterial
#define MATERIAL_ALPHAMODULATE			27
#define MATERIAL_SETMATERIALVARFLAG     29 // alt: 30

// replay
#define REPLAY_GETGLOBALVARS			13

// input
#define INPUT_GETUSERCMD				8

// client
#define CLIENT_INIT						0
#define CLIENT_IN_KEYEVENT				20
#define CLIENT_CREATEMOVE				21
#define CLIENT_FRAMESTAGENOTIFY			35

// engine
#define ENGINE_CLIENTCMD_UNRESTRICTED	106

// panel
#define PANEL_GETNAME					36
#define PANEL_PAINTTRAVERSE				41

//surface
#define SURFACE_DRAWSETCOLOUR			11
#define SURFACE_DRAWFILLEDRECT			12
#define SURFACE_DRAWOUTLINEDRECT		14
#define SURFACE_DRAWLINE				15
#define SURFACE_DRAWSETTEXTFONT			17
#define SURFACE_DRAWSETTEXTCOLOUR		19
#define SURFACE_DRAWSETTEXTPOS			20
#define SURFACE_DRAWPRINTTEXT			22
#define SURFACE_CREATEFONT				66
#define SURFACE_SETFONTGLYPHSET			67
#define SURFACE_GETTEXTSIZE				75
#define SURFACE_DRAWOUTLINEDCIRCLE		99
#define SURFACE_DRAWCOLOREDCIRCLE		160

// =================================================

//////////////////////////////////////////////////////////////////////////
// Bones

#define BONE_PELVIS			0
#define BONE_L_THIGH		1
#define BONE_L_CALF			2
#define BONE_L_FOOT			3
#define BONE_L_TOE			4
#define BONE_R_THIGH		5
#define BONE_R_CALF			6
#define BONE_R_FOOT			7
#define BONE_R_TOE			8
#define BONE_SPINE0			9
#define BONE_SPINE1			10
#define BONE_SPINE2			11
#define BONE_SPINE3			12
#define BONE_NECK			13
#define BONE_HEAD			14
#define BONE_L_CLAVICLE		15
#define BONE_L_UPPERARM		16
#define BONE_L_FOREARM		17
#define BONE_L_HAND			18
#define BONE_L_FINGER2_0	19
#define BONE_L_FINGER2_1	20
#define BONE_L_FINGER2_2	21
#define BONE_L_FINGER1_0	22
#define BONE_L_FINGER1_1	23
#define BONE_L_FINGER1_2	24
#define BONE_L_FINGER0_0	25
#define BONE_L_FINGER0_1	26
#define BONE_L_FINGER0_2	27
#define BONE_R_CLAVICLE		28
#define BONE_R_UPPERARM		29
#define BONE_R_FOREARM		30
#define BONE_R_HAND			31
#define BONE_R_FINGER2_0	32
#define BONE_R_FINGER2_1	33
#define BONE_R_FINGER2_2	34
#define BONE_R_FINGER1_0	35
#define BONE_R_FINGER1_1	36
#define BONE_R_FINGER1_2	37
#define BONE_R_FINGER0_0	38
#define BONE_R_FINGER0_1	39
#define BONE_R_FINGER0_2	40
#define BONE_R_WRIST		41
#define BONE_L_WRIST		42
#define BONE_L_ULNA			43
#define BONE_R_ULNA			44
#define BONE_WEAPON_BONE	45
#define BONE_WEAPON_BONE_RIGHTHAND	46
#define BONE_WEAPON_BONE_LEFTHAND	47
#define BONE_WEAPON_BONE_CLIP		48
#define BONE_FORWARD				49

const BYTE TeamT = 2;																// T Team
const BYTE TeamCT = 3;																// CT Team
const BYTE TeamSpec = 0;															// Spectator

#define	FL_ONGROUND					(1 << 0)

#define IN_ATTACK					(1 << 0)
#define IN_JUMP						(1 << 1)
#define IN_DUCK						(1 << 2)
#define IN_FORWARD					(1 << 3)
#define IN_BACK						(1 << 4)
#define IN_USE						(1 << 5)
#define IN_CANCEL					(1 << 6)
#define IN_LEFT						(1 << 7)
#define IN_RIGHT					(1 << 8)
#define IN_MOVELEFT					(1 << 9)
#define IN_MOVERIGHT				(1 << 10)
#define IN_ATTACK2					(1 << 11)
#define IN_RUN						(1 << 12)
#define IN_RELOAD					(1 << 13)
#define IN_ALT1						(1 << 14)
#define IN_ALT2						(1 << 15)
#define IN_SCORE					(1 << 16)
#define IN_SPEED					(1 << 17)
#define IN_WALK						(1 << 18)
#define IN_ZOOM						(1 << 19)
#define IN_WEAPON1					(1 << 20)
#define IN_WEAPON2					(1 << 21)
#define IN_BULLRUSH					(1 << 22)

#define	CONTENTS_SOLID			0x1
#define	CONTENTS_WINDOW			0x2
#define CONTENTS_MOVEABLE		0x4000
#define	CONTENTS_MONSTER		0x2000000
#define	CONTENTS_DEBRIS			0x4000000
#define CONTENTS_HITBOX			0x40000000
#define	CONTENTS_MONSTERCLIP	0x20000
#define	CONTENTS_GRATE			0x8
#define MASK_NPCWORLDSTATIC			(CONTENTS_SOLID|CONTENTS_WINDOW|CONTENTS_MONSTERCLIP|CONTENTS_GRATE)
#define	MASK_SHOT	(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_HITBOX)

#define MASK_HITBOX (CONTENTS_SOLID|CONTENTS_WINDOW|CONTENTS_MONSTERCLIP|CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_DEBRIS|CONTENTS_HITBOX)
#define MASK_DEFAULT (CONTENTS_SOLID|CONTENTS_WINDOW|CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_DEBRIS|CONTENTS_HITBOX)

typedef void* (*CreateInterfaceFn)(const char *pName, int *pReturnCode);

namespace WeaponIds
{
	enum Ids
	{
		Base = 0,
		P228,
		Glock,
		Scout,
		HEGrenade,
		XM1014,
		C4,
		MAC10,
		Aug,
		SmokeGrenade,
		Elite,
		FiveSeven,
		UMP45,
		SG550,
		Galil,
		Famas,
		USP,
		AWP,
		MP5Navy,
		M249,
		M3,
		M4A1,
		TMP,
		G3SG1,
		Flashbang,
		Deagle,
		SG552,
		AK47,
		Knife,
		P90    
	};
}

enum MaterialVarFlags_t
{
	MATERIAL_VAR_DEBUG					  = (1 << 0),
	MATERIAL_VAR_NO_DEBUG_OVERRIDE		  = (1 << 1),
	MATERIAL_VAR_NO_DRAW				  = (1 << 2),
	MATERIAL_VAR_USE_IN_FILLRATE_MODE	  = (1 << 3),

	MATERIAL_VAR_VERTEXCOLOR			  = (1 << 4),
	MATERIAL_VAR_VERTEXALPHA			  = (1 << 5),
	MATERIAL_VAR_SELFILLUM				  = (1 << 6),
	MATERIAL_VAR_ADDITIVE				  = (1 << 7),
	MATERIAL_VAR_ALPHATEST				  = (1 << 8),
	MATERIAL_VAR_MULTIPASS				  = (1 << 9),
	MATERIAL_VAR_ZNEARER				  = (1 << 10),
	MATERIAL_VAR_MODEL					  = (1 << 11),
	MATERIAL_VAR_FLAT					  = (1 << 12),
	MATERIAL_VAR_NOCULL					  = (1 << 13),
	MATERIAL_VAR_NOFOG					  = (1 << 14),
	MATERIAL_VAR_IGNOREZ				  = (1 << 15),
	MATERIAL_VAR_DECAL					  = (1 << 16),
	MATERIAL_VAR_ENVMAPSPHERE			  = (1 << 17),
	MATERIAL_VAR_NOALPHAMOD				  = (1 << 18),
	MATERIAL_VAR_ENVMAPCAMERASPACE	      = (1 << 19),
	MATERIAL_VAR_BASEALPHAENVMAPMASK	  = (1 << 20),
	MATERIAL_VAR_TRANSLUCENT              = (1 << 21),
	MATERIAL_VAR_NORMALMAPALPHAENVMAPMASK = (1 << 22),
	MATERIAL_VAR_NEEDS_SOFTWARE_SKINNING  = (1 << 23),
	MATERIAL_VAR_OPAQUETEXTURE			  = (1 << 24),
	MATERIAL_VAR_ENVMAPMODE				  = (1 << 25),
	MATERIAL_VAR_SUPPRESS_DECALS		  = (1 << 26),
	MATERIAL_VAR_HALFLAMBERT			  = (1 << 27),
	MATERIAL_VAR_WIREFRAME                = (1 << 28),
	MATERIAL_VAR_ALLOWALPHATOCOVERAGE     = (1 << 29),
};

#define DISPSURF_FLAG_SURFACE		(1<<0)
#define DISPSURF_FLAG_WALKABLE		(1<<1)
#define DISPSURF_FLAG_BUILDABLE		(1<<2)
#define DISPSURF_FLAG_SURFPROP1		(1<<3)
#define DISPSURF_FLAG_SURFPROP2		(1<<4)

#define	MAX_EDICT_BITS			11
#define NUM_ENT_ENTRY_BITS		(MAX_EDICT_BITS + 1)
#define NUM_ENT_ENTRIES			(1 << NUM_ENT_ENTRY_BITS)
#define ENT_ENTRY_MASK			(NUM_ENT_ENTRIES - 1)


#define InputFindPatternA "\xB9\x00\x00\x00\x00\xE8\x00\x00\x00\x00\x68\x00\x00\x00\x00\xC7\x05\x00\x00\x00\x00\x00\x00\x00\x00\xE8\x00\x00\x00\x00\x59\xC3\x68\x00\x00\x00\x00\x68\x00\x00\x00\x00\x68\x00\x00\x00\x00\x68\x00\x00\x00\x00\xB9\x00\x00\x00\x00"
#define InputFindPatternB "x????x????x????xx????????x????xxx????x????x????x????x????"
#define InputPatternOffset 1

#define RadarStructFindPatternA "\xC7\x06\x00\x00\x00\x00\x74\x11\x8D\x45\xFC\x50\xB9\x00\x00\x00\x00\x89\x75\xFC\xE8\x00\x00\x00\x00"
#define RadarStructFindPatternB "xx????xxxxxxx????xxxx????"
#define RadarStructOffset 13

#define RadarFindPatternA "\xC7\x06\x00\x00\x00\x00\x74\x11\x8D\x45\xFC\x50\xB9\x00\x00\x00\x00\x89\x75\xFC\xE8\x00\x00\x00\x00"
#define RadarFindPatternB "xx????xxxxxxx????xxxx????"
#define RadarPatternOffset 13

#define FlashFindPatternA "\x33\xC0\x39\x0D\x00\x00\x00\x00\x0F\x94\xC0\xC3"
#define FlashFindPatternB "xxxx????xxxx"
#define FlashPatternOffset 4

#define FlashOffsetFindPatternA "\x0F\x2F\x80\x00\x00\x00\x00\x0F\x87\x00\x00\x00\x00\x8B\x0D\x00\x00\x00\x00\x8B\x11\x8B\x82\x00\x00\x00\x00"
#define FlashOffsetFindPatternB "xxx????xx????xx????xxxx????"
#define FlashOffsetPatternOffset 3